//
//  YGSurveyBLL.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/24.
//

#import "YGSurveyBLL.h"
#import "CNHTTPManager.h"
@implementation YGSurveyBLL


+(void)requestServerDetailWithData:(NSString *)dateStr
                            typeId:(NSString *)typeId
                               num:(NSInteger)num
                           Success:(void (^)(YGServerDetailModel *model))success
                             fail:(void (^)(NSError *error))fail{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic fa_setObjectSafe:dateStr forKey:@"date"];
    [dic fa_setObjectSafe:typeId forKey:@"typeId"];
    [dic fa_setObjectSafe:@(num) forKey:@"num"];

    [[CNHTTPManager shared] GET:YG_FOOD_SERVER_DETAIL_URL parameters:dic success:^(id responeObj) {
            NSDictionary *data = [responeObj objectForKey:@"data"];
        YGServerDetailModel *model = [[YGServerDetailModel alloc] initWithDictionary:data error:nil];
        if (success) {
            success(model);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}


+(void)requestServerWithData:(NSString *)dateStr
                            typeId:(NSString *)typeId
                           Success:(void (^)(YGServerFoodModel *model))success
                        fail:(void (^)(NSError *error))fail{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic fa_setObjectSafe:dateStr forKey:@"date"];
    [dic fa_setObjectSafe:typeId forKey:@"type"];

    [[CNHTTPManager shared] GET:YG_FOOD_SERVER_URL parameters:dic success:^(id responeObj) {
            NSDictionary *data = [responeObj objectForKey:@"data"];
        YGServerFoodModel *model = [[YGServerFoodModel alloc] initWithDictionary:data error:nil];
        if (success) {
            success(model);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}

+(void)requestServerTypeWithSuccess:(void (^)(NSArray <YGFoodServerTypeModel *> *model))success
                               fail:(void (^)(NSError *error))fail{
    [[CNHTTPManager shared] GET:YG_FOOD_SERVER_Type parameters:nil success:^(id responeObj) {
        NSArray *data = [responeObj objectForKey:@"data"];
        NSArray *model = [YGFoodServerTypeModel arrayOfModelsFromDictionaries:data];
        if (success) {
            success(model);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}

+ (void)requestSave{
    [[CNHTTPManager shared] GET:YG_FOOD_SERVER_SAVE_URL parameters:nil success:^(id responeObj) {
      
        } failure:^(NSError *error, NSString *errorDes) {
          
        }];
}
@end
